package 力扣;

import java.util.Arrays;

public class 两数之和 {
    public static void main(String[] args) {
        int []nums1={-1,-2,-3,-4,-5};
        int []nums2={2,7,11,15};
        int[] ints = twoSum(nums2, 9);
        System.out.println(Arrays.toString(ints));
        int target=9;
        for (int i = 0; i <nums1.length ; i++) {
            for (int j = i+1; j <nums1.length ; j++) {
                if (nums1[i]+nums1[j]==target){
                   // System.out.println(Arrays.toString(new int[]{i,j}));
                }
            }
        }
    }
    public static int[] twoSum(int[] nums, int target) {
        for (int i = 0; i <nums.length ; i++) {
            for (int j = i+1; j <nums.length ; j++) {
                if (target<nums[i]&&nums[j]>0){
                    continue;
                }
                if (nums[i]+nums[j]==target){
                    return new int[]{i,j};
                }
            }
        }
        return null;
    }

}
